//
//  NSString+Extensional.m
//  MuYing
//
//  Created by tbb on 2019/7/23.
//  Copyright © 2019 TBB. All rights reserved.
//

#import "NSString+Extensional.h"

@implementation NSString (Extensional)
+(NSString *)classToClassNameStr:(Class)aclass {
    NSString *str = NSStringFromClass(aclass);
    NSArray *arr = [str componentsSeparatedByString:@"."];
    if (arr.count > 1) {
        str = arr.lastObject;
    }
    return str;
}

- (NSString *)removeStringSpace

{
    
    NSString *temp = [self stringByReplacingOccurrencesOfString:@" " withString:@""];
    
    return temp;
    
}

+ (NSAttributedString *)stringWithUIImage:(NSString *) contentStr image:(UIImage *)image rect:(CGRect)rect {
    
    // 创建一个富文本
    NSMutableAttributedString * attriStr = [[NSMutableAttributedString alloc] initWithString:contentStr];
    /**
     添加图片到指定的位置
     */
    NSTextAttachment *attchImage = [[NSTextAttachment alloc] init];
    // 设置图片大小
    attchImage.bounds = rect;//CGRectMake(0, 0, 30, 18);
    
    attchImage.image = image;

    NSAttributedString *stringImage = [NSAttributedString attributedStringWithAttachment:attchImage];
    [attriStr insertAttributedString:stringImage atIndex:0];
    
//    NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
//    [paragraphStyle1 setLineSpacing:5];
//    [attriStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [contentStr length])];
//
//    [attriStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0, contentStr.length)];
    
    return attriStr;
}
@end
